<?php
/**
 * Created by PhpStorm.
 * User: 18879810386
 * Date: 2016/10/28
 * Time: 10:40
 */header('content-type:text/html;charset=utf-8');
require './function.php';
dbinit();
if(!empty($_POST)){
    $fields=array('e_name','e_dept','date_of_birth','date_of_entry');
    $value=array();
    foreach ($fields as $k=>$v) {
        $date = isset($_post[$v]) ? $_POST[$v] : '';
        if ($date == '') die($v . '字段不能为空');
        $date = safeHandle($link,$date);
        $fields[$k] = "`$v`";
        $values[] = "'$data'";
        }
    $fields=implode(',',$fields);
        $values=implode(',',$values);
        $sql="insert into `emp_info`($fields) values ($values)";
    if($res=query($link,$sql)){header('Location:./showlist.php');
    die;}
    else{die('员工添加失败！');}
    }
define('APP','itcast');
require './add_html.php';?>